#ifndef _UDS_H_
#define _UDS_H_

#include <string.h>

typedef unsigned char U8;
typedef unsigned short U16;
typedef unsigned int U32;
typedef signed char S8;
typedef signed short S16;
typedef signed int S32;
typedef unsigned char BOOL;

#ifndef NULL 
 #define NULL 0
#endif

#ifndef FALSE 
 #define FALSE 0
#endif

#ifndef TRUE 
 #define TRUE 1
#endif

typedef enum
{
	UDS_SESSION_MODE_DEFAULT = 1,
	UDS_SESSION_MODE_PROGRAM,
	UDS_SESSION_MODE_EXTEND
}UDS_SessionMode;

typedef enum
{
	UDS_RESP_TYPE_NEGATIVE,
	UDS_RESP_TYPE_POSITIVE
}UDS_ResponseType;

typedef enum
{
    UDS_NRC_SUCCESS = 0x0,
    UDS_NRC_SERVICE_NOT_SUPPORTED = 0x11,
    UDS_NRC_SUB_FUNCTION_NOT_SUPPORTED = 0x12,
    UDS_NRC_INCORRECT_LENGTH_OR_FORMAT = 0x13,
    UDS_NRC_CONDITIONS_NOT_CORRECT = 0x22,
    UDS_NRC_REQUEST_OUT_OF_RANGE = 0x31,
    UDS_NRC_SECURITY_ACCESS_DENIED = 0x33,
    UDS_NRC_INVALID_KEY = 0x35,
    UDS_NRC_TOO_MANY_ATTEMPS = 0x36,
    UDS_NRC_TIME_DELAY_NOT_EXPIRED = 0x37,
    UDS_NRC_RESPONSE_PENDING = 0x78
} UDS_NegativeResponseCode;

typedef struct
{
	U16 id;
	U8 dlc;
	U8 data[8];
}UDS_CanMsg;

typedef struct
{
	U8 serviceId;
	U8 addrMode;
	U8 *parameterPtr;
	U16 parameterLen;
}UDS_Request;

typedef struct
{
	U8 serviceId;
	U8 type;
	U8 nrc;
	U8 *parameterPtr;
	U16 parameterLen;
}UDS_Response;

extern void UDS_sendResponse(UDS_Response * responsePtr);
extern void UDS_recvCanFrame(UDS_CanMsg * recvCanMsgPtr);
extern void UDS_100msTick();

#endif